package org.ala.shopping_test.shopping_center.repository.order_test.dao;

import org.ala.tiktools.mybatis.pager.Pagement;
import java.util.List;
import org.ala.tiktools.mybatis.pager.Pager;
import org.apache.ibatis.annotations.Mapper;
import org.ala.tiktools.mybatis.commons.AbstractMultipUpdate;
import org.ala.shopping_test.shopping_center.repository.order_test.entity.ShoppingOrder20250324Fields;
import org.ala.shopping_test.shopping_center.repository.order_test.entity.ShoppingOrder20250324DO;
import org.ala.shopping_test.shopping_center.repository.order_test.orderBy.ShoppingOrder20250324OrderBy;
import org.ala.shopping_test.shopping_center.repository.order_test.query.ShoppingOrder20250324Query;
import org.apache.ibatis.annotations.Param;

/**
 *	Dao (shopping_order_20250324)
 *  订单总表
 *
 *	@author 骆毅 (ala)
 *	@date 2025-03-24 23:08:24
 */
@Mapper
public interface ShoppingOrder20250324Mapper {

    /**
     *  查询全部数据（慎用！！！）
     */
    List<ShoppingOrder20250324DO> findAll(@Param("fields") ShoppingOrder20250324Fields fields);

    /**
     *  条件查询
     *  <p> 多个query之间是or的关系
     */
    List<ShoppingOrder20250324DO> findByQuery(@Param("fields") ShoppingOrder20250324Fields fields, @Param("query") ShoppingOrder20250324Query query);
    /**
     *  条件查询
     *  <p> 多个query之间是or的关系
     */
    List<ShoppingOrder20250324DO> findByQueryWithOrderBy(
                @Param("fields") ShoppingOrder20250324Fields fields,
                @Param("orderBy") ShoppingOrder20250324OrderBy orderBy,
                @Param("query") ShoppingOrder20250324Query query);

    /**
     *  查询总数（慎用！！！）
     */
    int count();
    /**
     *  条件查询数量
     *  <p> 多个query之间是or的关系
     */
    int countByQuery(@Param("fields") ShoppingOrder20250324Fields fields, @Param("query") ShoppingOrder20250324Query query);
    /**
     *  分页查询
     *  <p> 多个query之间是or的关系
     */
    @Pagement(count="countByQuery")
    Pager<ShoppingOrder20250324DO> findByPage(
                @Param("fields") ShoppingOrder20250324Fields fields,
                @Param("page") Pager<ShoppingOrder20250324DO> pager,
                @Param("query") ShoppingOrder20250324Query query);
    /**
     *  分页查询
     *  <p> 多个query之间是or的关系
     */
    @Pagement(count="countByQuery")
    Pager<ShoppingOrder20250324DO> findByPageWithOrderBy(
                @Param("fields") ShoppingOrder20250324Fields fields,
                @Param("page") Pager<ShoppingOrder20250324DO> pager,
                @Param("orderBy") ShoppingOrder20250324OrderBy orderBy,
                @Param("query") ShoppingOrder20250324Query query);


    int countByCreateTimeGteLte(
            @Param("createTimeGte") Long createTimeGte, @Param("createTimeLte") Long createTimeLte);
    @Pagement(count="countByCreateTimeGteLte")
    Pager<ShoppingOrder20250324DO> findByCreateTimeGteLte(
            @Param("createTimeGte") Long createTimeGte, @Param("createTimeLte") Long createTimeLte,
            @Param("page") Pager<ShoppingOrder20250324DO> pager);


    /**
     *  插入
     *  <p> 如果存在唯一自增主键字段，则insert完成后该字段保存该条记录自增的值
     */
    void insert(@Param("entity") ShoppingOrder20250324DO entity);
    /**
     *  批量插入
     *  <p> 如果存在唯一自增主键字段，则insert完成后该字段保存该条记录自增的值
     */
    void multipleInsert(@Param("entities") List<ShoppingOrder20250324DO> entities);


    /**
     *  修改
     *  <p> 多个query之间是or的关系
     */
    int update(@Param("entity") ShoppingOrder20250324DO entity, @Param("query") ShoppingOrder20250324Query query);
    /**
     *  批量修改
     *  <p> 每个MultipleUpdate对应一个update语句
     */
    int multipleUpdate(@Param("updates") List<MultipleUpdate> multipleUpdates);


    /**
     *  删除
     */
    int delete(@Param("query") ShoppingOrder20250324Query query);


    /**
     *  批量修改参数
     */
    public static class MultipleUpdate extends AbstractMultipUpdate<ShoppingOrder20250324DO, ShoppingOrder20250324Query> {
        public MultipleUpdate(ShoppingOrder20250324DO entity, ShoppingOrder20250324Query query) {
            super(entity, query);
        }
        public static MultipleUpdate build(ShoppingOrder20250324DO entity, ShoppingOrder20250324Query query) {
            return new MultipleUpdate(entity, query);
        }
        /**
         *  copy（注：这是浅拷贝）
         */
        public MultipleUpdate copy() {
            return new MultipleUpdate(entity.copy(), query.copy());
        }
    }
}